//滚动事件
import { ref } from "vue"
import { useWindowEvent } from "./event"

export const useWindowScrollStatus = () => {
        const status = ref(false)
        const judgeScrollStatusHandler = () => {
            const { scrollTop } = document.documentElement
            status.value = scrollTop > 0 ? true : false
        }
        useWindowEvent("scroll", judgeScrollStatusHandler)
        return status
    }
    //滚动条点击页码按钮时候让页面平滑的滚动上去  为了复用
export const useWindowScrollTo = (position, behavior = "smooth") => {
    window.scrollTo({
        ...position,
        //解构出来
        behavior
    })
}